//
// Created by DELL on 2025/2/13.
//

#ifndef RESULT_H
#define RESULT_H
#include "Any.h"
#include "Semaphore.h"
#include "TaskBase.h"

namespace zdotp {
    class TaskBase;
    class Result {
    public:
        Result(std::shared_ptr<TaskBase> task, bool is_valid);
        ~Result() = default;

        void set_value(Any any);
        Any get();
    private:
        Any any_;
        Semaphore sem_;
        std::shared_ptr<TaskBase> task_;
        std::atomic_bool is_valid_;
    };

} // zdotp

#endif //RESULT_H
